<?
require_once "qi/init.php";

$nome = @$_REQUEST["nome"];
$email = @$_REQUEST["email"];

$captcha = new Qi_Captcha();

$correto = $captcha->verificar();

$captcha->gerar_chave();
?>
<html>
	<head>
		<style>
			.correto, .errado {
				padding: 10px;
				text-align: center;
				background-color: lightblue;
				font-weight: bold;
				font-size: 18px;
				font-family: Georgia
				color: green;
			}
			.errado {
				color: darkred;
				background-color: yellow;
			}
		</style>
	</head>
	<body>
		<? if ($correto): ?>
			<div class="correto">CORRETO!</div>
		<? else: ?>
			<div class="errado">ERRADO!</div>
		<? endif ?>
		<form method="post">
			<table>
				<tr>
					<td>Nome:</td>
					<td><input name="nome" value="<?=h($nome)?>" /></td>
				</tr>
				<tr>
					<td>Email:</td>
					<td><input name="email" value="<?=h($email)?>" /></td>
				</tr>
				<tr>
					<td colspan="2">Digite o codigo da imagem abaixo</td>
				</tr>
				<tr>
					<td colspan="2">
						<?= $captcha->img_input() ?>
					</td>
				</tr>
				<tr>
					<td colspan="2"><input type="submit" value="Enviar" /></td>
				</tr>
			</table>
		</form>
	</body>
</html>